import { Global, Module } from '@nestjs/common';
import * as Minio from 'minio';
import { ConfigService } from '@nestjs/config';
import { MinioService } from './minio.service';
export const MINIO_CLIENT = 'MINIO_CLIENT';

@Global()
@Module({
    providers: [
        {
            provide: MINIO_CLIENT,
            async useFactory(config: ConfigService) {
                return new Minio.Client({
                    endPoint: config.get('minio.endPoint'),
                    port: config.get('minio.port'),
                    useSSL: config.get('minio.useSSL'),
                    accessKey: config.get('minio.accessKey'),
                    secretKey: config.get('minio.secretKey')
                })
            },
            inject: [ConfigService]
        },
        MinioService
    ],
    exports: [MinioService]
})
export class MinioModule { }